// const baseUrl = 'http://192.168.0.101:8081/yuhui'
// const baseUrl = 'http://192.168.0.113:8888/yuhui'
const baseUrl = 'https://xuegean.com/yuhui'
const fetch = {
  post: (url, param) => {
    return (
      new Promise((resolve, reject) => {
        wx.request({
          url: `${baseUrl}${url}`,
          data: param,
          header: {
            'Content-Type': 'application/x-www-form-urlencoded',
            'AUTH-TOKEN': wx.getStorageSync('tooken')
          },
          method: 'POST',
          success: res => {
            if (res.data.code === 200) {
              resolve(res.data.data)
            } else {
              reject(res.data)
            }
          },
          fail: error => {
            reject(error)
          }
        })
      })
    ) 
  }
}

export default fetch